package com.senlingspace.web.controller.headquarters;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.senlingspace.system.domain.dto.EquipmentLogDto;
import com.senlingspace.system.domain.vo.SlkjEquipmentLogVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.system.domain.SlkjEquipmentLog;
import com.senlingspace.system.service.ISlkjEquipmentLogService;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.common.core.page.TableDataInfo;

/**
 * 设备变更Controller
 * 
 * @author SenlingSpace
 * @date 2024-10-10
 */
@RestController
@RequestMapping("/system/log")
public class SlkjEquipmentLogController extends BaseController
{
    @Autowired
    private ISlkjEquipmentLogService slkjEquipmentLogService;

    /**
     * 查询设备变更列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquipmentLogDto equipmentLogDto)
    {
        startPage();
        List<SlkjEquipmentLogVo> list = slkjEquipmentLogService.selectEquipmentUpdateLogList(equipmentLogDto);
        return getDataTable(list);
    }

    /**
     * 导出设备变更列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "设备变更", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlkjEquipmentLog slkjEquipmentLog)
    {
        List<SlkjEquipmentLog> list = slkjEquipmentLogService.selectSlkjEquipmentLogList(slkjEquipmentLog);
        ExcelUtil<SlkjEquipmentLog> util = new ExcelUtil<SlkjEquipmentLog>(SlkjEquipmentLog.class);
        util.exportExcel(response, list, "设备变更数据");
    }

    /**
     * 获取设备变更详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slkjEquipmentLogService.selectSlkjEquipmentLogById(id));
    }

    /**
     * 新增设备变更
     */
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "设备变更", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlkjEquipmentLog slkjEquipmentLog)
    {
        return toAjax(slkjEquipmentLogService.insertSlkjEquipmentLog(slkjEquipmentLog));
    }

    /**
     * 修改设备变更
     */
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "设备变更", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlkjEquipmentLog slkjEquipmentLog)
    {
        return toAjax(slkjEquipmentLogService.updateSlkjEquipmentLog(slkjEquipmentLog));
    }

    /**
     * 删除设备变更
     */
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "设备变更", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slkjEquipmentLogService.deleteSlkjEquipmentLogByIds(ids));
    }
}
